﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PlayingCards.Model.Result;
using PlayingCards.Service.EntityService;
using PlayingCards.Service.IEntityService;

namespace PlayingCards.Api.Controllers
{
    /// <summary>
    ///  登录
    /// </summary>
    [AllowAnonymous]
    public class LoginController : BaseController
    {
        private readonly ILogger _logger;
        private readonly IUserService _userService;
        public LoginController(ILogger<LoginController> logger,IUserService userService) 
        {
            _logger = logger;
            _userService = userService;
        }

        /// <summary>
        ///  登录
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result<string>> Login(string name)
        {
            try
            {
               return await _userService.Login(name);
            }
            catch (Exception ex)
            {
                _logger.LogError($"登录异常");
                return new Result<string> { Status = false };
            }
        }

       
    }
}
